// JointCommand.cpp: implementation of the JointCommand class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "phsshare.h"
#include "JointCommand.h"
#include "AutoJointGenerator.h"
#include "Joint.h"

#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

JointCommand::JointCommand(Part* pFirst, Part* pNext)
{
	ASSERT(pFirst);
	ASSERT(pNext);

	m_pFirst = pFirst;
	m_pNext = pNext;
}

JointCommand::~JointCommand()
{

}

BOOL JointCommand::Execute()
{
	Joint* pJoint = GetJoint();
	if(pJoint == NULL)
		return FALSE;
	return pJoint->Execute();
}

Joint* JointCommand::GetJoint()
{
	AutoJointGenerator generator(m_pFirst, m_pNext);

	Joint* pJoint = generator.Generate();
	ASSERT(pJoint);

	return pJoint;

}
